package cn.doitedu.sql;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

public class _20_GenericInMemoryCatalog_Demo {

    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        StreamTableEnvironment tenv = StreamTableEnvironment.create(env);



        tenv.executeSql("create database doit46").print();

        tenv.executeSql(
                " create table score_kfk_1(                                 "+
                        "       user_id int,                                    "+
                        "       course string,                                  "+
                        " 	    score double                                     "+
                        "  ) with (                                              "+
                        "       'connector' = 'kafka',                           "+
                        "       'topic' = 'score-test',                            "+
                        "       'properties.bootstrap.servers' = 'doitedu:9092', "+
                        "       'properties.group.id' = 'g003',                  "+
                        "       'scan.startup.mode' = 'latest-offset',           "+
                        "       'value.format' = 'json',                         "+
                        "       'value.fields-include' = 'EXCEPT_KEY'            "+
                        " )                                                      "
        );


        tenv.executeSql("use doit46");
        tenv.executeSql(
                " create table score_kfk_2(                                 "+
                        "       user_id int,                                    "+
                        "       course string,                                  "+
                        " 	    score double                                     "+
                        "  ) with (                                              "+
                        "       'connector' = 'kafka',                           "+
                        "       'topic' = 'score-test',                            "+
                        "       'properties.bootstrap.servers' = 'doitedu:9092', "+
                        "       'properties.group.id' = 'g003',                  "+
                        "       'scan.startup.mode' = 'latest-offset',           "+
                        "       'value.format' = 'json',                         "+
                        "       'value.fields-include' = 'EXCEPT_KEY'            "+
                        " )                                                      "
        );


        tenv.executeSql("show databases").print();

        tenv.executeSql("use default_database").print();
        tenv.executeSql("show tables").print();

        System.out.println("------------------------------");

        tenv.executeSql("use doit46").print();
        tenv.executeSql("show tables").print();



    }

}
